package net.chrone.quickpayapi.api;

import org.apache.commons.lang.StringUtils;

import net.chrone.quickpayapi.model.CiticWxBaseBean;
import net.chrone.quickpayapi.model.Merchant;
import net.chrone.quickpayapi.model.Order;
import net.chrone.quickpayapi.util.Constant;

/**
 * 扫码收款工具类
 * @author Jerry
 */
public class QrcodeApi {
	
	/**
	 * 非固定码扫码
	 * @param order:订单信息
	 * @param merchant：商户信息
	 * @param subject：商品title
	 */
	public static void getQrcode(Order order,Merchant merchant){
		if(Constant.TRAN_TP_0==order.getTranTp()){//T0
			getT0Qrcode(order, merchant);
		}
	}

	public static void getT0Qrcode(Order order,Merchant merchant){
		String channelId = order.getPayChannelId();
		if(Constant.CHNL_CODE_CITIC.equals(channelId)){//中信
			CiticWxBaseBean bean = CiticApi.qrpay(order);
			if(bean!=null&&StringUtils.isNotEmpty(bean.getCodeUrl())){
				order.setQrcodeUrl(bean.getCodeUrl());
			}
			order.setBankRspCd(bean.getResult_code());
			order.setBankRspDesc(bean.getResult_code());
		}
	}
	
	
}
